package com.ruoyi.web.controller.share;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.share.domain.ShareAllocationMoneyUser;
import com.ruoyi.share.service.IShareAllocationMoneyUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分账用户Controller
 *
 * @author ruoyi
 * @date 2021-11-16
 */
@RestController
@RequestMapping("/api/shoreuser")
public class ShareAllocationMoneyUserController extends BaseController
{
    @Autowired
    private IShareAllocationMoneyUserService shareAllocationMoneyUserService;

    /**
     * 查询分账用户列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ShareAllocationMoneyUser shareAllocationMoneyUser)
    {
        startPage();
        List<ShareAllocationMoneyUser> list = shareAllocationMoneyUserService.selectShareAllocationMoneyUserList(shareAllocationMoneyUser);
        return getDataTable(list);
    }

    /**
     * 导出分账用户列表
     */
    @GetMapping("/export")
    public AjaxResult export(ShareAllocationMoneyUser shareAllocationMoneyUser)
    {
        List<ShareAllocationMoneyUser> list = shareAllocationMoneyUserService.selectShareAllocationMoneyUserList(shareAllocationMoneyUser);
        ExcelUtil<ShareAllocationMoneyUser> util = new ExcelUtil<ShareAllocationMoneyUser>(ShareAllocationMoneyUser.class);
        return util.exportExcel(list, "分账用户数据");
    }

    /**
     * 获取分账用户详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(shareAllocationMoneyUserService.selectShareAllocationMoneyUserById(id));
    }

    /**
     * 新增分账用户
     */
    @PostMapping
    public AjaxResult add(@RequestBody ShareAllocationMoneyUser shareAllocationMoneyUser)
    {
        return toAjax(shareAllocationMoneyUserService.insertShareAllocationMoneyUser(shareAllocationMoneyUser));
    }

    /**
     * 修改分账用户
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ShareAllocationMoneyUser shareAllocationMoneyUser)
    {
        return toAjax(shareAllocationMoneyUserService.updateShareAllocationMoneyUser(shareAllocationMoneyUser));
    }

    /**
     * 删除分账用户
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shareAllocationMoneyUserService.deleteShareAllocationMoneyUserByIds(ids));
    }
}
